<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>计算器</title>
	</head>
	<body style="font-family: '微软雅黑';">
		<p>
			整数1: <input type="text" name="" id="num1"/>
		</p>
		<p>
			整数2: <input type="text" name="" id="num2" />
		</p>
		<p>
			<button onclick="a(1)">相加</button>
			<button onclick="a(2)">相减</button>
			<button onclick="a(3)">相乘</button>
			<button onclick="a(4)">相除</button>
		</p>
		<p>
			结果 :  <input type="text" name="" id="num"/>
		</p>
		<script type="text/javascript">
			function a(n){
				
				var ii = document.querySelector("#num1").value;
				var iii = document.querySelector("#num2").value;
				ii = Number(ii);
				iii = Number(iii);
				
			if(n == 1){
				document.querySelector("#num").value = ii + iii;
			}
			if(n == 2){
				document.querySelector("#num").value = ii - iii;
			}
			if(n == 3){
				document.querySelector("#num").value = ii * iii;
			}
			if(n == 4){
				document.querySelector("#num").value = ii / iii;
			}
			}
		</script>
	</body>
</html>
